package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatUserCollectDto;
import com.usaas.search.service.IPlatUserCollectService;
/**
 * 用户收藏Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platUserCollect")
public class AdminPlatUserCollectController extends BaseController {

    @Autowired
    private IPlatUserCollectService platUserCollectService;

    /**
     * 查询用户收藏列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:list')")
    @Log(title = "管理端用户收藏list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatUserCollectDto platUserCollectDto) {
        List<PlatUserCollectDto> list = platUserCollectService.queryList(platUserCollectDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询用户收藏分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:list')")
    @Log(title = "管理端用户收藏page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatUserCollectDto platUserCollectDto) {
        return platUserCollectService.queryPage(platUserCollectDto);
    }


    /**
     * 导出用户收藏列表
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:export')")
    @Log(title = "管理端导出用户收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatUserCollectDto platUserCollectDto) {
        List<PlatUserCollectDto> list = platUserCollectService.queryList(platUserCollectDto);
        ExcelUtil<PlatUserCollectDto> util = new ExcelUtil<>(PlatUserCollectDto.class);
        util.exportExcel(response, list, "用户收藏数据");
    }

    /**
     * 获取用户收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:query')")
    @Log(title = "管理端获取用户收藏详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatUserCollectDto platUserCollectDto) {
        return AjaxResult.success(platUserCollectService.queryById(platUserCollectDto.getId()));
    }

    /**
     * 新增用户收藏
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:add')")
    @Log(title = "管理端新增用户收藏", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatUserCollectDto platUserCollectDto) {
        return toAjax(platUserCollectService.add(platUserCollectDto));
    }

    /**
     * 修改用户收藏
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:edit')")
    @Log(title = "管理端修改用户收藏", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatUserCollectDto platUserCollectDto) {
        return toAjax(platUserCollectService.update(platUserCollectDto));
    }

    /**
     * 删除用户收藏
     */
    @PreAuthorize("@ss.hasPermi('search:platUserCollect:remove')")
    @Log(title = "管理端删除用户收藏", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatUserCollectDto platUserCollectDto) {
        return toAjax(platUserCollectService.removeBatch(platUserCollectDto.getIds()));
    }

}
